package com.socialuni.center.web.serive.api;

import com.socialuni.sdk.constant.AuthType;
import com.socialuni.center.web.model.DO.user.DevAccountProviderDO;
import com.socialuni.center.web.serive.app.OAuthService;
import com.socialuni.center.web.utils.DevAccountUtils;
import com.socialuni.sdk.model.DO.user.UserDO;
import com.socialuni.sdk.model.RO.SocialOAuthUserRO;
import com.socialuni.sdk.model.RO.UniLoginRO;
import com.socialuni.sdk.model.QO.OAuthUserInfoQO;
import com.socialuni.sdk.store.SocialUserPhoneStore;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;


@Service
public class MockApplySocialOAuthService {
    @Resource
    OAuthService oAuthService;

    @Resource
    SocialUserPhoneStore socialUserPhoneStore;
    //默认会根据微信的appid去生成不太对，应该用咱们系统的appid
    //为什么需要appid和渠道类型，因为需要去判断获取对应的开发者账户

    public UniLoginRO<SocialOAuthUserRO> mockOAuthUserInfo(String mpType) {

        UniLoginRO<SocialOAuthUserRO> applySocialUniOAuthRO = mockOAuthUserInfo(mpType, AuthType.user);

        return applySocialUniOAuthRO;
    }

    public UniLoginRO<SocialOAuthUserRO> mockOAuthUserPhoneNum(String mpType) {

        UniLoginRO<SocialOAuthUserRO> applySocialUniOAuthRO = mockOAuthUserInfo(mpType, AuthType.phone);

        return applySocialUniOAuthRO;
    }

    private UniLoginRO<SocialOAuthUserRO> mockOAuthUserInfo(String mpType, String authType) {
        DevAccountProviderDO devAccountProviderDO = DevAccountUtils.getDevAccountProviderDO(mpType);

        OAuthUserInfoQO authVO = new OAuthUserInfoQO(devAccountProviderDO.getAppId(), devAccountProviderDO.getMpType());

        UserDO userDO = DevAccountUtils.getDevAccountUserDO();

        return oAuthService.oAuthUserInfo(authVO, userDO, authType);
    }

}